<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class REXML::Attributes - rexml: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Hash
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-3C-3C">#&lt;&lt;</a>
    <li ><a href="#method-i-5B-5D">#[]</a>
    <li ><a href="#method-i-5B-5D-3D">#[]=</a>
    <li ><a href="#method-i-add">#add</a>
    <li class="calls-super" ><a href="#method-i-delete">#delete</a>
    <li ><a href="#method-i-delete_all">#delete_all</a>
    <li ><a href="#method-i-each">#each</a>
    <li ><a href="#method-i-each_attribute">#each_attribute</a>
    <li ><a href="#method-i-get_attribute">#get_attribute</a>
    <li ><a href="#method-i-get_attribute_ns">#get_attribute_ns</a>
    <li ><a href="#method-i-length">#length</a>
    <li ><a href="#method-i-namespaces">#namespaces</a>
    <li ><a href="#method-i-prefixes">#prefixes</a>
    <li ><a href="#method-i-size">#size</a>
    <li ><a href="#method-i-to_a">#to_a</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-REXML::Attributes">
    <h1 id="class-REXML::Attributes" class="class">
      class REXML::Attributes
    </h1>

    <section class="description">
    
<p>A class that defines the set of <a href="Attributes.html"><code>Attributes</code></a> of an <a href="Element.html"><code>Element</code></a> and provides operations for accessing elements in that set.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(element)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates and returns a new REXML::Attributes object. The element given by argument <code>element</code> is stored, but its own attributes are not modified:</p>

<pre class="ruby"><span class="ruby-identifier">ele</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;foo&#39;</span>)
<span class="ruby-identifier">attrs</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Attributes</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ele</span>)
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">object_id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">object_id</span> <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Other instance methods in class REXML::Attributes may refer to:</p>
<ul><li>
<p><code>element.document</code>.</p>
</li><li>
<p><code>element.prefix</code>.</p>
</li><li>
<p><code>element.expanded_name</code>.</p>
</li></ul>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2160</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span> <span class="ruby-identifier">element</span>
  <span class="ruby-ivar">@element</span> = <span class="ruby-identifier">element</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-3C-3C" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">&lt;&lt;</span><span
                                class="method-args">( attribute )</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Attributes.html#method-i-add">add</a>
                            </div>
                          </div>

                  <div id="method-i-5B-5D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          [name] &rarr; attribute_value or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the value for the attribute given by <code>name</code>, if it exists; otherwise <code>nil</code>. The value returned is the unnormalized attribute value, with entities expanded:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>] <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-string">&#39;att&#39;</span>]     <span class="ruby-comment"># =&gt; &quot;&lt;&quot;</span>
<span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-string">&#39;bar:att&#39;</span>] <span class="ruby-comment"># =&gt; &quot;2&quot;</span>
<span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-string">&#39;nosuch&#39;</span>]  <span class="ruby-comment"># =&gt; nil</span>
</pre>

<p>Related: <a href="Attributes.html#method-i-get_attribute"><code>get_attribute</code></a> (returns an Attribute object).</p>

                              <div class="method-source-code" id="5B-5D-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2185</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">attr</span> = <span class="ruby-identifier">get_attribute</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">value</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">nil?</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-5B-5D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          [name] = value &rarr; value
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>When <code>value</code> is non-<code>nil</code>, assigns that to the attribute for the given <code>name</code>, overwriting the previous value if it exists:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>] <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">attrs</span> = <span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>
<span class="ruby-identifier">attrs</span>[<span class="ruby-string">&#39;foo:att&#39;</span>] = <span class="ruby-string">&#39;2&#39;</span> <span class="ruby-comment"># =&gt; &quot;2&quot;</span>
<span class="ruby-identifier">attrs</span>[<span class="ruby-string">&#39;baz:att&#39;</span>] = <span class="ruby-string">&#39;3&#39;</span> <span class="ruby-comment"># =&gt; &quot;3&quot;</span>
</pre>

<p>When <code>value</code> is <code>nil</code>, deletes the attribute if it exists:</p>

<pre class="ruby"><span class="ruby-identifier">attrs</span>[<span class="ruby-string">&#39;baz:att&#39;</span>] = <span class="ruby-keyword">nil</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;baz:att&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

                              <div class="method-source-code" id="5B-5D-3D-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2369</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]=</span>( <span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span> )
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span>             <span class="ruby-comment"># Delete the named attribute</span>
    <span class="ruby-identifier">attr</span> = <span class="ruby-identifier">get_attribute</span>(<span class="ruby-identifier">name</span>)
    <span class="ruby-identifier">delete</span> <span class="ruby-identifier">attr</span>
    <span class="ruby-keyword">return</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Attribute</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span>.<span class="ruby-identifier">doctype</span>
      <span class="ruby-identifier">value</span> = <span class="ruby-constant">Text</span><span class="ruby-operator">::</span><span class="ruby-identifier">normalize</span>( <span class="ruby-identifier">value</span>, <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span>.<span class="ruby-identifier">doctype</span> )
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">value</span> = <span class="ruby-constant">Text</span><span class="ruby-operator">::</span><span class="ruby-identifier">normalize</span>( <span class="ruby-identifier">value</span>, <span class="ruby-keyword">nil</span> )
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">value</span> = <span class="ruby-constant">Attribute</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">value</span>.<span class="ruby-identifier">element</span> = <span class="ruby-ivar">@element</span>
  <span class="ruby-identifier">old_attr</span> = <span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">value</span>.<span class="ruby-identifier">name</span>, <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">old_attr</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">store</span>(<span class="ruby-identifier">value</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">old_attr</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Hash</span>
    <span class="ruby-identifier">old_attr</span>[<span class="ruby-identifier">value</span>.<span class="ruby-identifier">prefix</span>] = <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">old_attr</span>.<span class="ruby-identifier">prefix</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">prefix</span>
    <span class="ruby-comment"># Check for conflicting namespaces</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">prefix</span> <span class="ruby-operator">!=</span> <span class="ruby-string">&quot;xmlns&quot;</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">old_attr</span>.<span class="ruby-identifier">prefix</span> <span class="ruby-operator">!=</span> <span class="ruby-string">&quot;xmlns&quot;</span>
      <span class="ruby-identifier">old_namespace</span> = <span class="ruby-identifier">old_attr</span>.<span class="ruby-identifier">namespace</span>
      <span class="ruby-identifier">new_namespace</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">namespace</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">old_namespace</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">new_namespace</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-constant">ParseException</span>.<span class="ruby-identifier">new</span>(
                <span class="ruby-node">&quot;Namespace conflict in adding attribute \&quot;#{value.name}\&quot;: &quot;</span><span class="ruby-operator">+</span>
                <span class="ruby-node">&quot;Prefix \&quot;#{old_attr.prefix}\&quot; = \&quot;#{old_namespace}\&quot; and &quot;</span><span class="ruby-operator">+</span>
                <span class="ruby-node">&quot;prefix \&quot;#{value.prefix}\&quot; = \&quot;#{new_namespace}\&quot;&quot;</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">store</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">name</span>, {<span class="ruby-identifier">old_attr</span>.<span class="ruby-identifier">prefix</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">old_attr</span>,
                       <span class="ruby-identifier">value</span>.<span class="ruby-identifier">prefix</span>    <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">value</span>}
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">store</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-ivar">@element</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-add" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          add(attribute) &rarr; attribute
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds attribute <code>attribute</code>, replacing the previous attribute of the same name if it exists; returns <code>attribute</code>:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>] <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">attrs</span> = <span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>
<span class="ruby-identifier">attrs</span> <span class="ruby-comment"># =&gt; {&quot;att&quot;=&gt;{&quot;foo&quot;=&gt;foo:att=&#39;1&#39;, &quot;bar&quot;=&gt;bar:att=&#39;2&#39;, &quot;&quot;=&gt;att=&#39;&amp;lt;&#39;}}</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Attribute</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;foo:att&#39;</span>, <span class="ruby-string">&#39;2&#39;</span>)) <span class="ruby-comment"># =&gt; foo:att=&#39;2&#39;</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Attribute</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;baz&#39;</span>, <span class="ruby-string">&#39;3&#39;</span>)) <span class="ruby-comment"># =&gt; baz=&#39;3&#39;</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;baz&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

                              <div class="method-source-code" id="add-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2537</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add</span>( <span class="ruby-identifier">attribute</span> )
  <span class="ruby-keyword">self</span>[<span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">attribute</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Attributes.html#method-i-3C-3C">&lt;&lt;</a>
                            </div>

                          </div>

                  <div id="method-i-delete" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete(name) &rarr; element
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete(attribute) &rarr; element
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Removes a specified attribute if it exists; returns the attributes’ element.</p>

<p>When string argument <code>name</code> is given, removes the attribute of that name if it exists:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>] <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">attrs</span> = <span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;foo:att&#39;</span>) <span class="ruby-comment"># =&gt; &lt;ele bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;foo:att&#39;</span>) <span class="ruby-comment"># =&gt; &lt;ele bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
</pre>

<p>When attribute argument <code>attribute</code> is given, removes that attribute if it exists:</p>

<pre class="ruby"><span class="ruby-identifier">attr</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Attribute</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;bar:att&#39;</span>, <span class="ruby-string">&#39;2&#39;</span>)
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">attr</span>) <span class="ruby-comment"># =&gt; &lt;ele att=&#39;&amp;lt;&#39;/&gt; # =&gt; &lt;ele att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">attr</span>) <span class="ruby-comment"># =&gt; &lt;ele att=&#39;&amp;lt;&#39;/&gt; # =&gt; &lt;ele/&gt;</span>
</pre>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="delete-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2490</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete</span>( <span class="ruby-identifier">attribute</span> )
  <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">prefix</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Attribute</span>
    <span class="ruby-identifier">name</span> = <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">name</span>
    <span class="ruby-identifier">prefix</span> = <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">prefix</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">attribute</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Namespace</span><span class="ruby-operator">::</span><span class="ruby-constant">NAMESPLIT</span>
    <span class="ruby-identifier">prefix</span>, <span class="ruby-identifier">name</span> = <span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>
    <span class="ruby-identifier">prefix</span> = <span class="ruby-string">&#39;&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">prefix</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">old</span> = <span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">name</span>, <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">old</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Hash</span> <span class="ruby-comment"># the supplied attribute is one of many</span>
    <span class="ruby-identifier">old</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">prefix</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">old</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
      <span class="ruby-identifier">repl</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-identifier">old</span>.<span class="ruby-identifier">each_value</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">repl</span> = <span class="ruby-identifier">v</span>}
      <span class="ruby-identifier">store</span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">repl</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">old</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-ivar">@element</span>
  <span class="ruby-keyword">else</span> <span class="ruby-comment"># the supplied attribute is a top-level one</span>
    <span class="ruby-keyword">super</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@element</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-delete_all" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete_all(name) &rarr; array_of_removed_attributes
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes all attributes matching the given <code>name</code>; returns an array of the removed attributes:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>] <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">attrs</span> = <span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">delete_all</span>(<span class="ruby-string">&#39;att&#39;</span>) <span class="ruby-comment"># =&gt; [att=&#39;&amp;lt;&#39;]</span>
</pre>

                              <div class="method-source-code" id="delete_all-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2559</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_all</span>( <span class="ruby-identifier">name</span> )
  <span class="ruby-identifier">rv</span> = []
  <span class="ruby-identifier">each_attribute</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">attribute</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">rv</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">attribute</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">expanded_name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">name</span>
  }
  <span class="ruby-identifier">rv</span>.<span class="ruby-identifier">each</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">attr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">remove</span> }
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">rv</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          each {|expanded_name, value| ... }
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Calls the given block with each expanded-name/value pair:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>]   <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">expanded_name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">p</span> [<span class="ruby-identifier">expanded_name</span>, <span class="ruby-identifier">value</span>]
<span class="ruby-keyword">end</span>
</pre>

<p>Output:</p>

<pre class="ruby">[<span class="ruby-string">&quot;foo:att&quot;</span>, <span class="ruby-string">&quot;1&quot;</span>]
[<span class="ruby-string">&quot;bar:att&quot;</span>, <span class="ruby-string">&quot;2&quot;</span>]
[<span class="ruby-string">&quot;att&quot;</span>, <span class="ruby-string">&quot;&lt;&quot;</span>]
</pre>

                              <div class="method-source-code" id="each-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2287</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">to_enum</span>(<span class="ruby-identifier">__method__</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-identifier">each_attribute</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attr</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">yield</span> [<span class="ruby-identifier">attr</span>.<span class="ruby-identifier">expanded_name</span>, <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">value</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each_attribute" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_attribute {|attr| ... }
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Calls the given block with each REXML::Attribute object:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>]   <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">each_attribute</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attr</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">p</span> [<span class="ruby-identifier">attr</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">attr</span>]
<span class="ruby-keyword">end</span>
</pre>

<p>Output:</p>

<pre class="ruby">[<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Attribute</span>, <span class="ruby-value">foo:</span><span class="ruby-identifier">att</span>=<span class="ruby-string">&#39;1&#39;</span>]
[<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Attribute</span>, <span class="ruby-value">bar:</span><span class="ruby-identifier">att</span>=<span class="ruby-string">&#39;2&#39;</span>]
[<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Attribute</span>, <span class="ruby-identifier">att</span>=<span class="ruby-string">&#39;&amp;lt;&#39;</span>]
</pre>

                              <div class="method-source-code" id="each_attribute-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2254</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_attribute</span> <span class="ruby-comment"># :yields: attribute</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">to_enum</span>(<span class="ruby-identifier">__method__</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-identifier">each_value</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Attribute</span>
      <span class="ruby-keyword">yield</span> <span class="ruby-identifier">val</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">val</span>.<span class="ruby-identifier">each_value</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">atr</span><span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span> <span class="ruby-identifier">atr</span> }
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get_attribute" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          get_attribute(name) &rarr; attribute_object or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the REXML::Attribute object for the given <code>name</code>:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>] <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">attrs</span> = <span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">get_attribute</span>(<span class="ruby-string">&#39;foo:att&#39;</span>)       <span class="ruby-comment"># =&gt; foo:att=&#39;1&#39;</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">get_attribute</span>(<span class="ruby-string">&#39;foo:att&#39;</span>).<span class="ruby-identifier">class</span> <span class="ruby-comment"># =&gt; REXML::Attribute</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">get_attribute</span>(<span class="ruby-string">&#39;bar:att&#39;</span>)       <span class="ruby-comment"># =&gt; bar:att=&#39;2&#39;</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">get_attribute</span>(<span class="ruby-string">&#39;att&#39;</span>)           <span class="ruby-comment"># =&gt; att=&#39;&amp;lt;&#39;</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">get_attribute</span>(<span class="ruby-string">&#39;nosuch&#39;</span>)        <span class="ruby-comment"># =&gt; nil</span>
</pre>

                              <div class="method-source-code" id="get_attribute-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2313</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_attribute</span>( <span class="ruby-identifier">name</span> )
  <span class="ruby-identifier">attr</span> = <span class="ruby-identifier">fetch</span>( <span class="ruby-identifier">name</span>, <span class="ruby-keyword">nil</span> )
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-comment"># Look for prefix</span>
    <span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Namespace</span><span class="ruby-operator">::</span><span class="ruby-constant">NAMESPLIT</span>
    <span class="ruby-identifier">prefix</span>, <span class="ruby-identifier">n</span> = <span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">prefix</span>
      <span class="ruby-identifier">attr</span> = <span class="ruby-identifier">fetch</span>( <span class="ruby-identifier">n</span>, <span class="ruby-keyword">nil</span> )
      <span class="ruby-comment"># check prefix</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">attr</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Attribute</span>
        <span class="ruby-keyword">return</span> <span class="ruby-identifier">attr</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">prefix</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">prefix</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">attr</span> = <span class="ruby-identifier">attr</span>[ <span class="ruby-identifier">prefix</span> ]
        <span class="ruby-keyword">return</span> <span class="ruby-identifier">attr</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">element_document</span> = <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">element_document</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">element_document</span>.<span class="ruby-identifier">doctype</span>
      <span class="ruby-identifier">expn</span> = <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">expanded_name</span>
      <span class="ruby-identifier">expn</span> = <span class="ruby-identifier">element_document</span>.<span class="ruby-identifier">doctype</span>.<span class="ruby-identifier">name</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">expn</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
      <span class="ruby-identifier">attr_val</span> = <span class="ruby-identifier">element_document</span>.<span class="ruby-identifier">doctype</span>.<span class="ruby-identifier">attribute_of</span>(<span class="ruby-identifier">expn</span>, <span class="ruby-identifier">name</span>)
      <span class="ruby-keyword">return</span> <span class="ruby-constant">Attribute</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">name</span>, <span class="ruby-identifier">attr_val</span> ) <span class="ruby-keyword">if</span> <span class="ruby-identifier">attr_val</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Hash</span>
    <span class="ruby-identifier">attr</span> = <span class="ruby-identifier">attr</span>[ <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">prefix</span> ]
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">attr</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get_attribute_ns" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          get_attribute_ns(namespace, name)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the REXML::Attribute object among the attributes that matches the given <code>namespace</code> and <code>name</code>:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>] <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">attrs</span> = <span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">get_attribute_ns</span>(<span class="ruby-string">&#39;http://foo&#39;</span>, <span class="ruby-string">&#39;att&#39;</span>)    <span class="ruby-comment"># =&gt; foo:att=&#39;1&#39;</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">get_attribute_ns</span>(<span class="ruby-string">&#39;http://foo&#39;</span>, <span class="ruby-string">&#39;nosuch&#39;</span>) <span class="ruby-comment"># =&gt; nil</span>
</pre>

                              <div class="method-source-code" id="get_attribute_ns-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2585</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_attribute_ns</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">result</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">each_attribute</span>() { <span class="ruby-operator">|</span><span class="ruby-identifier">attribute</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">&amp;&amp;</span>
      <span class="ruby-identifier">namespace</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">namespace</span>() <span class="ruby-operator">&amp;&amp;</span>
      ( <span class="ruby-operator">!</span><span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">fully_expanded_name</span>.<span class="ruby-identifier">index</span>(<span class="ruby-string">&#39;:&#39;</span>) )
      <span class="ruby-comment"># foo will match xmlns:foo, but only if foo isn&#39;t also an attribute</span>
      <span class="ruby-identifier">result</span> = <span class="ruby-identifier">attribute</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">result</span> <span class="ruby-keyword">or</span> <span class="ruby-operator">!</span><span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">or</span>
                            <span class="ruby-operator">!</span><span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">fully_expanded_name</span>.<span class="ruby-identifier">index</span>(<span class="ruby-string">&#39;:&#39;</span>)
    <span class="ruby-keyword">end</span>
  }
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-length" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          length
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the count of attributes:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>]   <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">length</span> <span class="ruby-comment"># =&gt; 3</span>
</pre>

                              <div class="method-source-code" id="length-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2225</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">length</span>
  <span class="ruby-identifier">c</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">each_attribute</span> { <span class="ruby-identifier">c</span><span class="ruby-operator">+=</span><span class="ruby-value">1</span> }
  <span class="ruby-identifier">c</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Attributes.html#method-i-size">size</a>
                            </div>

                          </div>

                  <div id="method-i-namespaces" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          namespaces
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a hash of name/value pairs for the namespaces:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;a xmlns=&quot;foo&quot; xmlns:x=&quot;bar&quot; xmlns:y=&quot;twee&quot; z=&quot;glorp&quot;/&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">namespaces</span> <span class="ruby-comment"># =&gt; {&quot;xmlns&quot;=&gt;&quot;foo&quot;, &quot;x&quot;=&gt;&quot;bar&quot;, &quot;y&quot;=&gt;&quot;twee&quot;}</span>
</pre>

                              <div class="method-source-code" id="namespaces-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2446</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">namespaces</span>
  <span class="ruby-identifier">namespaces</span> = {}
  <span class="ruby-identifier">each_attribute</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attribute</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">namespaces</span>[<span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">value</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">prefix</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;xmlns&#39;</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;xmlns&#39;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span>.<span class="ruby-identifier">doctype</span>
    <span class="ruby-identifier">expn</span> = <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">expanded_name</span>
    <span class="ruby-identifier">expn</span> = <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span>.<span class="ruby-identifier">doctype</span>.<span class="ruby-identifier">name</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">expn</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
    <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span>.<span class="ruby-identifier">doctype</span>.<span class="ruby-identifier">attributes_of</span>(<span class="ruby-identifier">expn</span>).<span class="ruby-identifier">each</span> {
      <span class="ruby-operator">|</span><span class="ruby-identifier">attribute</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">namespaces</span>[<span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">value</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">prefix</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;xmlns&#39;</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;xmlns&#39;</span>
    }
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">namespaces</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-prefixes" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          prefixes &rarr; array_of_prefix_strings
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of prefix strings in the attributes. The array does not include the default namespace declaration, if one exists.</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-string">&#39;&lt;a xmlns=&quot;foo&quot; xmlns:x=&quot;bar&quot; xmlns:y=&quot;twee&quot; z=&quot;glorp&quot;/&gt;&#39;</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">prefixes</span> <span class="ruby-comment"># =&gt; [&quot;x&quot;, &quot;y&quot;]</span>
</pre>

                              <div class="method-source-code" id="prefixes-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2421</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">prefixes</span>
  <span class="ruby-identifier">ns</span> = []
  <span class="ruby-identifier">each_attribute</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attribute</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">ns</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">name</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">prefix</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;xmlns&#39;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span>.<span class="ruby-identifier">doctype</span>
    <span class="ruby-identifier">expn</span> = <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">expanded_name</span>
    <span class="ruby-identifier">expn</span> = <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span>.<span class="ruby-identifier">doctype</span>.<span class="ruby-identifier">name</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">expn</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
    <span class="ruby-ivar">@element</span>.<span class="ruby-identifier">document</span>.<span class="ruby-identifier">doctype</span>.<span class="ruby-identifier">attributes_of</span>(<span class="ruby-identifier">expn</span>).<span class="ruby-identifier">each</span> {
      <span class="ruby-operator">|</span><span class="ruby-identifier">attribute</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">ns</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">name</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">attribute</span>.<span class="ruby-identifier">prefix</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;xmlns&#39;</span>
    }
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ns</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-size" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">size</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Attributes.html#method-i-length">length</a>
                            </div>
                          </div>

                  <div id="method-i-to_a" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_a &rarr; array_of_attribute_objects
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of REXML::Attribute objects representing the attributes:</p>

<pre class="ruby"><span class="ruby-identifier">xml_string</span> = <span class="ruby-identifier">&lt;&lt;-EOT</span>
<span class="ruby-value">  &lt;root xmlns:foo=&quot;http://foo&quot; xmlns:bar=&quot;http://bar&quot;&gt;
     &lt;ele foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;
  &lt;/root&gt;
</span><span class="ruby-identifier">EOT</span>
<span class="ruby-identifier">d</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml_string</span>)
<span class="ruby-identifier">ele</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-string">&#39;//ele&#39;</span>]   <span class="ruby-comment"># =&gt; &lt;a foo:att=&#39;1&#39; bar:att=&#39;2&#39; att=&#39;&amp;lt;&#39;/&gt;</span>
<span class="ruby-identifier">attrs</span> = <span class="ruby-identifier">ele</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">to_a</span>      <span class="ruby-comment"># =&gt; [foo:att=&#39;1&#39;, bar:att=&#39;2&#39;, att=&#39;&amp;lt;&#39;]</span>
<span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">class</span>                <span class="ruby-comment"># =&gt; REXML::Attribute</span>
</pre>

                              <div class="method-source-code" id="to_a-source">
            <pre><span class="ruby-comment"># File rexml-3.2.6/lib/rexml/element.rb, line 2207</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_a</span>
  <span class="ruby-identifier">enum_for</span>(<span class="ruby-value">:each_attribute</span>).<span class="ruby-identifier">to_a</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

